//
//  AppStack.h
//  iCodeMac
//
//  Created by Andrew Barry on 27/02/09.
//  Copyright 2009 Barry Computer Services. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@class FormView;
@class AppModule;
@class FlippedView;
@class JSVirtualMachine;

@interface AppStack : NSObject {
	NSString *path;
	NSMutableArray *modules;
	IBOutlet NSWindow *window;
	bool isRunning, isPaused;
	FormView *editView;
	FlippedView *runView;
	AppModule *currentModule;
	NSView *pauseView;
	JSVirtualMachine *vm;
	NSUndoManager *undoManager;

	@public JSRuntime *rt;
	@public JSContext *cx; 
	@public JSObject *global, *globalProto; 
}
-(id)initWithPath: (NSString *) path;
-(NSUndoManager *)undoManager;
-(void)propChange: (NSArray *)data;
-(void)showAsWindow;
-(void)switchToEditor;
-(bool)switchToRuntime;
-(void)runtimeErrorMessage: (NSString *) message withReport: (JSErrorReport *) report;
-(void)pause;
-(bool)isRunning;
-(void)saveToPath: (NSString *) path;
-(void)update;
-(void)updateTitle;

-(JSVirtualMachine *)vm;

+(AppStack *)stackForContext: (JSContext *) cx;
@end

extern NSMutableArray *gActiveStacks;